package cn.gzmli.dtt.common.utils;

/**
 * sql 字符串处理工具
 * @author wonderful
 * @date 20180502
 */
public class SQLUtils {

	public static String escapeSql(String str) {
		if (str == null) {
			return null;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < str.length(); i++) {
			char src = str.charAt(i);
			switch (src) {
			case '\'':
				sb.append("''");
				break;
			case '\"':
				break;
			case '\\':
				sb.append("\\\\\\\\");
				break;
			default:
				sb.append(src);
				break;
			}
		}
		return sb.toString();
	}
	
}
